package com.kitty.game.equip.handler;

import com.kitty.game.role.model.Role;
import com.kitty.game.equip.model.RoleEquip;
import com.kitty.game.equip.model.RoleEquipField;
import com.kitty.game.config.Equip;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;
import java.util.List;
import com.kitty.game.equip.handler.RefineHandler;

/**
 * 炼化黄属性
 */
@Component("EquipRefineGold")
public class EquipRefineGoldHandler extends RefineHandler {
    /**
     * 炼化之后装备的颜色
     */
    private static final String THIS_COLOR = "金色";
    /**
     * 会被修改的颜色
     */
    private static final String BEFORE_COLOR = "粉色";
    /**
     * 炼化需要的水晶
     */
    private static final String CRYSTAL_NAME = "黄水晶";
    /**
     * 炼化成功提示
     */
    private static final String NOT_REQ_COLOR = "#R{0}#n没有炼化粉属性，无法炼化黄属性。";
    /**
     * 炼化属性的FIELDID
     */
    private static final short THIS_FIELDID = 1026;
    /**
     * 不能跟什么属性重复
     */
    private static final short DIFF_FIELDID = 770;
    /**
     * 预览炼化属性的FIELDID
     */
    private static final short PRE_THIS_FIELDID = 6146;

    @Override
    public String getOperStr() {
        return "炼化黄属性";
    }

    @Override
    public String getBeforeColor() {
        return BEFORE_COLOR;
    }

    @Override
    public String getThisColor() {
        return THIS_COLOR;
    }

    @Override
    public String getCrystal() {
        return CRYSTAL_NAME;
    }

    @Override
    protected void addSuitFixedField(int fixedField, RoleEquip roleEquip, Equip equip, int polor) {

    }

    @Override
    public List<Integer> getSuitFieldId(int pos, int polar) {
        return null;
    }

    @Override
    public short getPreField() {
        return PRE_THIS_FIELDID;
    }

    @Override
    public short getField() {
        return THIS_FIELDID;
    }

    @Override
    public short getSuitField() {
        return 0;
    }

    @Override
    public short getPreSuitField() {
        return 0;
    }

    @Override
    public Short getDiffField() {
        return DIFF_FIELDID;
    }

    @Override
    public String checkResource(Object... objects) {
        Role role = (Role) objects[0];
        String param = (String) objects[1];
        RoleEquip roleEquip = (RoleEquip) objects[2];

        String noEnough = super.checkResource(role, param, roleEquip);
        if (noEnough != null) {
            return noEnough;
        }
        RoleEquipField roleEquipField = roleEquip.getFields().get(getDiffField());
        if (roleEquipField == null) {
            return MessageFormat.format(NOT_REQ_COLOR, roleEquip.getName(), BEFORE_COLOR);
        }
        return null;
    }

    @Override
    public int needCash(short level, int pos) {
        return level < 70 ? 0 : level * level * 24 + 7500;
    }

    @Override
    public String getUpdateTypeStr() {
        return "gold_refine";
    }

}
